#include<bits/stdc++.h>
using namespace std;
int main()
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	long long n,l,r;
	scanf("%lld%lld%lld",&n,&l,&r);
	long long ans=0;
	ans=l%n;
	if(n-ans-1<=r-l)
	{
		ans=n-1;	
	}	
	else
	{
		ans+=r-l;
	}
	printf("%lld",ans);
} 
